<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<style>
ul {margin:0;padding:0}
li{list-style:none; border-bottom:1px solid red;}
.active {background:#0FC;}
</style>
<script>
window.onload = function (){
 var aLi = document.getElementsByTagName('li');
 var oldLi = '';
 
 for(var i=0;i<aLi.length;i++){
  aLi[i].onclick = function(){
   oldLi.className = '';
   this.className = 'active';
   oldLi = this;
  }
 }
}
</script>
</head>
<ul>
 <li>a</li>
 <li>s</li>
 <li>d</li>
 <li>v</li>
</ul>
<body>
</body>
</html>
